//
//  CZBaseTableViewController.swift
//  weibo
//
//  Created by 丁蒙 on 16/6/25.
//  Copyright © 2016年 丁蒙. All rights reserved.
//

import UIKit

class CZBaseTableViewController: UITableViewController {

    var visitorView:CZVisitorView?
    
    let isLogin: Bool = CZUserAccountTools.sharedUserAccountTools.isLogin
    
    
    override func viewDidLoad() {
        super.viewDidLoad()
        
        if isLogin {
            super.loadView()
            return
        }else {
            setUpVisitorView()
        }
        
    }
        //MARK - 设置访客视图
        private func setUpVisitorView() {
        
        setNav()
       visitorView = CZVisitorView()
        
        visitorView?.compose = {
            self.barButtonClick()
        }
        
        view = visitorView
        
        
        
    }
    // MARK: - 设置导航栏
    private func setNav() {
        navigationItem.leftBarButtonItem = UIBarButtonItem(title: "登录", style: UIBarButtonItemStyle.Plain, target: self, action: #selector(CZBaseTableViewController.barButtonClick));
        navigationItem.rightBarButtonItem = UIBarButtonItem(title: "注册", style: UIBarButtonItemStyle.Plain, target: self, action: #selector(CZBaseTableViewController.barButtonClick));
    }
    // MARK: - 导航栏登录按钮点击事件
    @objc private func barButtonClick() {
        
        let OAuthVC = CZOAuthViewController()
        let nav = CZNavViewController(rootViewController: OAuthVC)
        navigationController?.presentViewController(nav, animated: true, completion: nil)
        
        
        
        
        
    }

}
